package com.axdoc.wallet.service.impl;

import java.sql.Timestamp;
import java.util.List;

import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;

import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.axdoc.wallet.dao.IPlatformWalletDao;
import com.axdoc.wallet.entity.PlatformWalletRecords;
import com.axdoc.wallet.exceptions.WalletBizException;
import com.axdoc.wallet.service.PlatformWalletService;

@Service("platformWalletService")
@Path("platform")
@Produces({ "application/json; charset=UTF-8", "text/xml; charset=UTF-8" })
public class PlatformWalletServiceImpl implements PlatformWalletService {
	
	@Autowired
	private IPlatformWalletDao platformWalletDao;

	@GET
	@POST
	@Path("/queryRecordsByTradeNo/")
	public List<PlatformWalletRecords> queryRecordsByTradeNo(@QueryParam("tradeNo") String tradeNo)
			throws WalletBizException, Exception {
		if (StringUtils.isBlank(tradeNo)) {
			throw new WalletBizException(WalletBizException.MISSING_ARGS, "缺少参数对象tradeNo");
		}
		return platformWalletDao.queryRecordsByTradeNo(tradeNo);
	}

	@GET
	@POST
	@Path("/queryRecordsByBizNo/")
	public List<PlatformWalletRecords> queryRecordsByBizNo(@QueryParam("bizNo") String bizNo)
			throws WalletBizException, Exception {
		if (StringUtils.isBlank(bizNo)) {
			throw new WalletBizException(WalletBizException.MISSING_ARGS, "缺少参数对象bizNo");
		}
		return platformWalletDao.queryRecordsByBizNo(bizNo);
	}

	@GET
	@POST
	@Path("/queryRecordsByTime/")
	public List<PlatformWalletRecords> queryRecordsByTime(@QueryParam("startTime") String startTime, @QueryParam("endTime") String endTime)
			throws WalletBizException, Exception {
		if (StringUtils.isBlank(startTime)) {
			throw new WalletBizException(WalletBizException.MISSING_ARGS, "缺少参数对象startTime");
		}
		if (StringUtils.isBlank(endTime)) {
			throw new WalletBizException(WalletBizException.MISSING_ARGS, "缺少参数对象endTime");
		}
		Timestamp st = Timestamp.valueOf(startTime);
		Timestamp et = Timestamp.valueOf(endTime);
		return platformWalletDao.queryRecordsByTime(st, et);
	}
	
	

}
